Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@quenty/binder

Package Overview
Dependencies
Maintainers
1
Versions
273
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@quenty/binder

Utility object to Bind a class to Roblox object, and associated helper methods

  • 1.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
73
decreased by-93.22%
Maintainers
1
Weekly downloads
 
Created
Source

Binder

Documentation Discord Build and release status

Binders bind a class to Roblox Instance

Installation

npm install @quenty/binder --save

Usage

-- Setup a class!
local MyClass = {}
MyClass.__index = MyClass

function MyClass.new(robloxInstance)
	print("New tagged instance of ", robloxInstance")
	return setmetatable({}, MyClass)
end

function MyClass:Destroy()
	print("Cleaning up")
	setmetatable(self, nil)
end

-- bind to every instance with tag of "TagName"!
local binder = Binder.new("TagName", MyClass)
binder:Start() -- listens for new instances and connects events

API

Binder.new(tagName, constructor)

Creates a new binder object.

Binder.isBinder(value)

Retrieves whether or not its a binder

Binder:Start()

Listens for new instances and connects to the GetInstanceAddedSignal() and removed signal!

Binder:GetTag()

Returns the tag name that the binder has

Binder:GetConstructor()

Returns whatever was set for the construtor. Used for meta-analysis of the binder, such as extracting new

Binder:ObserveInstance(inst, callback)

Fired when added, and then after removal, but before destroy!

Binder:GetClassAddedSignal()

Returns a new signal that will fire whenever a class is bound to the binder

Binder:GetClassRemovingSignal()

Returns a new signal that will fire whenever a class is removed from the binder

Binder:GetAll()

Returns all of the classes in a new table

local birdBinder = Binder.new("Bird", require("Bird")) -- Load bird into binder

-- Update every bird every frame
RunService.Stepped:Connect(function()
	for _, bird in pairs(birdBinder:GetAll()) do
		bird:Update()
	end
end)

Binder:GetAllSet()

Faster method to get all items in a binder

NOTE: Do not mutate this set directly

local birdBinder = Binder.new("Bird", require("Bird")) -- Load bird into binder

-- Update every bird every frame
RunService.Stepped:Connect(function()
	for bird, _ in pairs(birdBinder:GetAllSet()) do
		bird:Update()
	end
end)

birdBinder:Start()

Binder:Bind(inst)

Binds an instance to this binder using collection service and attempts to return it if it's bound properly. See BinderUtils.promiseBoundClass() for a safe way to retrieve it.

NOTE: Do not assume that a bound object will be retrieved

Binder:Unbind(inst)

Unbinds the instance by removing the tag

Binder:BindClient(inst)

See :Bind(). Acknowledges the risk of doing this on the client. Using this acknowledges that we're intentionally binding on a safe client object, i.e. one without replication. If another tag is changed on this instance, this tag will be lost/changed.

Binder:UnbindClient(inst)

See Unbind(), acknowledges risk of doing this on the client.

Binder:Get(inst)

Returns a version of the clas

Binder:Promise(inst, cancelToken)

Binder:Destroy()

Cleans up all bound classes, and disconnects all events

Keywords

FAQs

Package last updated on 31 Jul 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc